package demo05ObserverPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: WangPeng
 * @createTime: 2022/11/09 20:37
 * @description:
 * @version: v1.0
 */
public class WpIPublic implements IPublic{
    private String message;

    private List<UserInterface> list = new ArrayList<>();

    @Override
    public void add(UserInterface userInterface) {
        list.add(userInterface);
    }

    @Override
    public void delete(UserInterface userInterface) {
        list.remove(userInterface);
    }

    @Override
    public void setMessage(String message) {
        this.message=message;
    }

    @Override
    public void sendAll() {
        for (UserInterface userInterface : list) {
            userInterface.getMessage(message);
        }
    }
}
